package com.firebird.app.fekpsl.adapter

import android.view.View
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.firebird.app.fekpsl.bean.Follow
import com.firebird.app.fekpsl.R
import com.firebird.app.fekpsl.utils.ImageLoader
import com.firebird.app.fekpsl.app.App.Companion.context

/**
 * Created by firebird on 2018/4/22.
 */
class MessagerAdapter : BaseQuickAdapter<Follow, BaseViewHolder>(R.layout.sword_friend_item_messager_list) {

    override fun convert(helper: BaseViewHolder?, item: Follow?) {
        item ?: return
        helper ?: return
        val index=helper.layoutPosition
        val username = if (item.is_explicit==1) item.nice_name else item.real_name
        helper
                .setText(R.id.tv_user_name, username)
                .addOnClickListener(R.id.iv_avatar)
        if (item.avatar_text.isNotEmpty()) {
            helper.getView<ImageView>(R.id.iv_avatar)
                    .visibility = View.VISIBLE
            context?.let {
                ImageLoader.load(it, item.avatar_text, helper.getView(R.id.iv_avatar))
            }
        } else {
            helper.getView<ImageView>(R.id.iv_avatar)
                    .visibility = View.GONE
        }
        val content = "评测16|合格12|优秀2"
        helper.setText(R.id.tv_content, content)
    }
}
